package com.csy.rabbit.commit.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    private int code;
    private String message;
    private T date;

    public static <T> Result<T> success(int code, String message, T t) {
        Result<T> result = new Result<>();
        result.code = code;
        result.message = message;
        result.date = t;
        return result;
    }

    public static <T> Result<T> success(T t) {
        return success(20000, "成功", t);
    }

    public static <T> Result<T> error(int code, String message, T t) {
        Result<T> result = new Result<>();
        result.code = code;
        result.message = message;
        result.date = t;
        return result;
    }

    public static <T> Result<T> error(T t) {
        return error(-1, "失败", null);
    }



}
